package nio;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;

public class FileUtils {
    public static void main(String[] args) {
        try {
            //NIO读文件
            BufferedReader reader = Files.newBufferedReader(Paths.get("D:\\skycolor.xcs"), StandardCharsets.UTF_8);
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }
            //NIO写文件
            BufferedWriter writer = Files.newBufferedWriter(Paths.get("D:\\noi_write.txt"), StandardCharsets.UTF_8);
            writer.write("noi-write-1\n");
            writer.write("noi-write-2\n");
            writer.write("noi-write-3\n");
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
